package cn.org.itool.ws.framework.netty.codec;

import cn.org.itool.ws.framework.netty.message.WsHandShake;
import cn.org.itool.ws.framework.protocol.service.ProtocolService;
import cn.org.itool.ws.framework.ws.WsServer;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageEncoder;

import java.util.List;

@ChannelHandler.Sharable
public class BizHandShakeEncoder extends MessageToMessageEncoder<WsHandShake> {

    protected final ProtocolService PROTOCOL_SERVICE = WsServer.PROTOCOL_SERVICE;

    @Override
    protected void encode(ChannelHandlerContext channelHandlerContext, WsHandShake msg, List<Object> out) throws Exception {

        out.add(PROTOCOL_SERVICE.encode(msg));
    }
}
